#ifndef _REACTOR_BIT_H
#define _REACTOR_BIT_H

/* event_bit_set - Set the current bit of the interval.
 * 
 * @n: The pointer of the interval. 
 * @bit: The bit wante to set.
 */
void inline event_bit_set(int *n, int bit)
{
	int i;
	int mask = 0x1;
	assert(n);
	for(i = 0x0;i < bit;i++) {
		mask *= 0x2;
	}
	(*n) |= mask;
}

/* event_bit_clear - Clear the current bit of the interval.
 * 
 * @n: The pointer of the interval. 
 * @bit: The bit want to clear.
 */
void inline event_bit_clear(int *n, int bit)
{
	int i;
	int mask = 0x1;
	assert(n);
	for(i = 0x0;i < bit;i++) {
		mask *= 0x2;
	}
	(*n) &= (~mask);
}

/* event_bit_switch - To find out whether the current bit set or cleared(Bit op.).
 * 
 * @n: The interval. 
 * @bit: The bit wante to get.
 */
int inline event_bit_switch(int n, int bit)
{
	return (n >> bit) & 0x1;
}

int inline event_bit_fast_switch(int n, int bit)
{
	return !!(n & bit);
}

#endif